case = int(input())
n, m = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(m):
    line = list(map(int, input().split()))
    op = line[0]
    l = line[1]
    r = line[2]
    if op == 1:
        d = line[3]
        for i in range(l - 1, r):
            arr[i] += d
    if op == 2:
        l2 = line[3]
        r2 = line[4]
        arr1 = list()
        for i in range(l2 - 1, r2):
            arr1.append(arr[i])
        for i in range(l - 1, r):
            arr[i] = arr1[i-l+1]
    if op == 3:
        sum = 0
        for i in range(l - 1, r):
            sum += arr[i]
        print(sum)
